package com.aidong.util;

import com.aidong.cache.ItemCache;
import com.aidong.dao.wills.ReportFileListDao;
import com.aidong.model.wills.ReportFileList;
import com.aidong.util.DateUtil;

import java.util.Date;
import java.util.List;
import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Repository;

@Repository
public class ReportUtil {
    private static Logger log = Logger.getLogger(ReportUtil.class);
    @Resource
    ReportFileListDao reportFileListDao;
    @Resource
    protected ItemCache cache;

    public ReportUtil() {
    }

    public void addReportFile(String reportFileType, String reportFileName, String reportFileChName, String filePath, String reportCreateDate, String shopCode) {
        List lst = this.reportFileListDao.getDataLstByFileNM(reportFileName);
        if (lst.size() > 0) {
            this.reportFileListDao.updateReportFileList(lst);
        } else {
            ReportFileList po = new ReportFileList();
            po.setCreateTime(new Date());
            po.setUpdateTime(new Date());
            po.setReportCreateDate(DateUtil.formatDate(reportCreateDate));
            po.setReportFileType(reportFileType);
            po.setReportFileName(reportFileName);
            po.setReportFileChName(reportFileChName);
            po.setReportFilePath(filePath);
            po.setShopCode(shopCode);
            this.reportFileListDao.add(po);
        }
    }
}
